home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13663 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  67 lines

  1. Path: howland.reston.ans.net!psinntp!psinntp!psinntp!psinntp!usenet
  2. From: annoying@usa.pipeline.com(Zachary Hartnett)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Problem with Borland C++ v4.52
  5. Date: 26 Mar 1996 17:53:58 GMT
  6. Organization: Pipeline USA
  7. Message-ID: <4j9avm$nh2@news1.h1.usa.pipeline.com>
  8. References: <4j973t$ctm@newsbf02.news.aol.com>
  9. NNTP-Posting-Host: 38.8.120.16
  10. X-PipeUser: annoying
  11. X-PipeHub: usa.pipeline.com
  12. X-PipeGCOS: (Zachary Hartnett)
  13. X-Newsreader: Pipeline v3.5.0
  14.  
  15. /* 
  16. roytoo@aol.com wrote: 
  17.  
  18. I am having a runtime problem with Borland C++ v4.52.  When I try to input 
  19. a real number (i.e. 12.5) using cin >> to a variable defined as a double, 
  20. float or long double, I get a "floating point: overflow" error.  This 
  21. problem disappears if I input numbers in the format:  1.25e1.  However, if 
  22. i use the format:  12.5e0, the runtime error occurs again. 
  23. */ 
  24.  
  25. #include <iostream.h> 
  26.  
  27. void main(void) 
  28.   float       valFloat; 
  29.   double      valDouble; 
  30.   long double valLDouble; 
  31.  
  32.   cout << "Input float value:"; 
  33.   cin >> valFloat; 
  34.  
  35.   cout << "Input double value:"; 
  36.   cin >> valDouble; 
  37.  
  38.   cout << "Input long double value:"; 
  39.   cin >> valLDouble; 
  40.  
  41.   cout << "float:      " << valFloat << '\n' 
  42.        << "double:     " << valDouble << '\n' 
  43.        << "long double:" << valLDouble; 
  44.  
  45. /* 
  46. G:\>bcc t 
  47. Borland C++ 4.52 Copyright (c) 1987, 1994 Borland International 
  48. t.cpp: 
  49. Turbo Link  Version 7.1.30.1. Copyright (c) 1987, 1996 Borland
  50. International 
  51.  
  52. G:\>t 
  53. Input float value:45.5 
  54. Input double value:1e+23 
  55. Input long double value:56 
  56. float:      45.5 
  57. double:     1e+23 
  58. long double:56 
  59. G:\> 
  60. */ 
  61.  
  62. // I'm not sure where your problem lies... Does this program work? 
  63. // If you are using printf or scanf, don't forget the & (reference
  64. operator).
  65.